package com.qf.config;


import com.qf.constant.RabbitMQConstants;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class RabbitMQConfig {

    // TOPIC_SMS_SEND_LOG的交换机
    @Bean
    public Exchange sendLogExchange(){
        return ExchangeBuilder.topicExchange(RabbitMQConstants.TOPIC_SMS_SEND_LOG + "_exchange").build();
    }

    // TOPIC_SMS_SEND_LOG的队列
    @Bean
    public Queue sendLogQueue(){
        return QueueBuilder.durable(RabbitMQConstants.TOPIC_SMS_SEND_LOG).build();
    }

    // TOPIC_SMS_SEND_LOG的绑定方式
    @Bean
    public Binding sendLogBinding(Queue sendLogQueue,Exchange sendLogExchange){
        return BindingBuilder.bind(sendLogQueue).to(sendLogExchange).with(RabbitMQConstants.BINDING).noargs();
    }

    // TOPIC_PUSH_SMS_REPORT的交换机
    @Bean
    public Exchange pushSmsReportExchange(){
        return ExchangeBuilder.topicExchange(RabbitMQConstants.TOPIC_PUSH_SMS_REPORT + "_exchange").build();
    }

    // TOPIC_PUSH_SMS_REPORT的队列
    @Bean
    public Queue pushSmsReportQueue(){
        return QueueBuilder.durable(RabbitMQConstants.TOPIC_PUSH_SMS_REPORT).build();
    }

    // TOPIC_PUSH_SMS_REPORT的绑定方式
    @Bean
    public Binding pushSmsReportBinding(Queue pushSmsReportQueue,Exchange pushSmsReportExchange){
        return BindingBuilder.bind(pushSmsReportQueue).to(pushSmsReportExchange).with(RabbitMQConstants.BINDING).noargs();
    }


}
